# -*- coding: utf-8 -*-
# @Time    : 2025/4/21 11:48
# @Author  : yxb
# @Email   : 18282090563@163.com
# @File    : record_diet_page.py
# @Software: PyCharm
from pages.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy
from time import sleep





class RecordDietPage(BasePage):

    '''首页加号'''
    btn_creat_locator = (AppiumBy.ID,'com.xiachufang:id/iv_home_upload')

    '''点击记饮食'''
    btn_record_diet_locator = (AppiumBy.XPATH,'//android.widget.LinearLayout[@resource-id="com.xiachufang:id/create_diet_btn"]/android.widget.ImageView')

    '''点击早餐'''
    breakfirst_locator = (AppiumBy.XPATH,'//android.view.View[@content-desc="早餐"]')

    # '''点击添加一个鸡蛋'''               #new UiSelector().description("鸡蛋热量 139 千卡 / 100 克碳水 2.4 克 / 100 克")
    # add_egg_locator = (AppiumBy.ANDROID_UIAUTOMATOR,r'new UiSelector().description("鸡蛋热量 139 千卡 / 100 克碳水 2.4 克 / 100 克")')
    # # add_egg_locator = (AppiumBy,tap(positions,duration=None))


    '''点击确定'''
    sure_btn_locator = (AppiumBy.XPATH,'//android.view.View[@content-desc="确定"]')

    '''点击完成'''
    complete_locator = (AppiumBy.XPATH,'//android.view.View[@content-desc="完成"]')

    def btn_creat(self):
        self.find_element(self.btn_creat_locator).click()
        sleep(2)

    def btn_record_diet(self):
        self.find_element(self.btn_record_diet_locator).click()
        sleep(2)

    def breakfirst(self):
        self.find_element(self.breakfirst_locator).click()
        sleep(2)

    def add_egg(self):
        self.driver.tap([(250,340)],duration=None)
        sleep(2)
    # def tap(positions, duration):
    #     driver.tap([(379,14)],1000)
    def sure_btn(self):
        self.find_element(self.sure_btn_locator).click()
        sleep(2)

    def complete(self):
        self.find_element(self.complete_locator).click()
        sleep(2)











